package homework.api.day01;

public class StringBuilderApiDemo {
    public static void main(String[] args) {
        String str = "abc";
        StringBuilder builder = new StringBuilder(str);
        StringBuilder builder1 = new StringBuilder("abc");

        //增加，在最后面添加，类似+
        builder.append("123");
        System.out.println(builder);

        //替换，含头不含尾，将选中的和字符串替换
        //开始下标最大=字符串长度
        //结束下标可以越界
        builder.replace(6,7,"ABC");
        System.out.println(builder);

        //删除，必须两个下标，含头不含尾
        //开始下标不可以越界
        builder.delete(5,30);
        System.out.println(builder);

        //插入，在下标位置开始插入
        builder.insert(2,"qwe");
        System.out.println(builder);
    }
}
